<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<div ng-controller="CubeCtrl" class="nav-tabs-custom" style="margin-top:40px;">
    <ul class="nav nav-tabs">
        <li class="{{(!cube.visiblePage || cube.visiblePage=='metadata')? 'active':''}}">
            <a href="" ng-click="cube.visiblePage='metadata'">Grid</a>
        </li>
        <!--</li>-->
        <li class="{{cube.visiblePage=='sql'? 'active':''}}">
            <a href="" ng-click="cube.visiblePage='sql';getCubeSql(cube)">SQL</a>
        </li>
        <li class="{{cube.visiblePage=='json'? 'active':''}}"
            ng-if="userService.hasRole('ROLE_ADMIN') || hasPermission(cube, 16) && !newAccess">
            <a href="" ng-click="cube.visiblePage='json';">JSON(Cube)</a>
        </li>
        <li class="{{cube.visiblePage=='access'? 'active':''}}">
            <a href="" ng-click="cube.visiblePage='access';listAccess(cube, 'CubeInstance');">Access</a>
        </li>
        <li class="{{cube.visiblePage=='notification'? 'active':''}}"
            ng-if="userService.hasRole('ROLE_ADMIN') || hasPermission(cube, 16) && !newAccess">
            <a href="" ng-click="cube.visiblePage='notification';getNotifyListString(cube);">Notification</a>
        </li>
        <li class="{{cube.visiblePage=='hbase'? 'active':''}}"
            ng-if="userService.hasRole('ROLE_ADMIN')">
            <a href="" ng-click="cube.visiblePage='hbase';getHbaseInfo(cube)">HBase</a>
        </li>
    </ul>

    <div class="cube-detail" ng-if="!cube.visiblePage || cube.visiblePage=='metadata'">
        <div ng-include="'partials/cubes/cube_schema.html'" ng-controller="CubeSchemaCtrl"
             ng-init="state={mode:'view', cubeName:cube.name};cubeState={isStreaming:(!!cube.streaming)?true:false}"></div>
    </div>

    <div ng-show="cube.visiblePage=='sql'" class="cube-detail">
        <div ng-if="cube.sql">
            <pre style="background-color: white;border: 0px">{{cube.sql}}</pre>
        </div>
        <div ng-if="!cube.sql">
            <span calss="text-info">No SQL GENERATED.</span>
        </div>
    </div>

    <div ng-show="cube.visiblePage=='json'" class="cube-detail">
        <pre ng-if="!state.jsonEdit"
             style="background-color: white;border: 0px">{{angular.toJson(cleanStatus(cube.detail), true)}}</pre>
    </div>

    <!--<div ng-show="cube.visiblePage=='json_model'" class="cube-detail">-->
          <!--<pre ng-if="!state.jsonEdit"-->
               <!--style="background-color: white;border: 0px">{{angular.toJson(cleanStatus(model), true)}}</pre>-->
    <!--</div>-->
    <!--<div ng-show="cube.visiblePage=='graph'" id="cube_graph_{{cube.name}}" class="cube-detail cube_graph">-->
    <!--</div>-->

    <div class="cube-detail" ng-if="cube.visiblePage=='access'">
        <div class="row">
            <div class="col-xs-1"></div>
            <div class="col-xs-10">
                <div ng-include src="'partials/common/access.html'" ng-init="entity=cube;type='CubeInstance';"></div>
            </div>
            <div class="col-xs-1"></div>
        </div>
    </div>

    <div class="cube-detail" ng-show="cube.visiblePage=='notification'">
        <div style="margin: 15px;">
            <form>
                <h5>Notification List(Comma Separated)</h5>
                <div class="form-group">
                    <input ng-model="cube.notifyListString" class="form-control" placeholder="Notification List..." />
                </div>
                <div class="form-group">
                    <button class="btn btn-primary btn-sm" ng-click="updateNotifyList(cube)">Save</button>
                </div>
                <div class="space-4"></div>
            </form>
        </div>
    </div>

  <div class="cube-detail" ng-show="cube.visiblePage=='hbase'">
        <div style="margin: 15px;">
            <div ng-repeat="table in cube.hbase">
                <h5><b>HTable:</b> {{table.tableName}}</h5>
                <ul>
                    <li>Region Count: <span class="red">{{table.regionCount}}</span></li>
                    <li>Size: <span class="red">{{table.tableSize | bytes}}</span></li>
                    <li>Start Time: <span class="red">{{table.dateRangeStart | reverseToGMT0}}</span></li>
                    <li>End Time: <span class="red">{{table.dateRangeEnd | reverseToGMT0}}</span></li>
                </ul>
            </div>
            <div ng-if="cube.hbase">
                <div class="hr hr8 hr-double hr-dotted"></div>
                <h5><b>Total Size:</b> <span class="red">{{cube.totalSize | bytes}}</span></h5>
                <h5><b>Total Number:</b> <span class="red">{{cube.hbase.length}}</span></h5>
            </div>
            <div ng-if="cube.hbase.length == 0">
                <h5>No HBase Info.</h5>
            </div>
        </div>
    </div>
  </div>

